type ToPromise<T> = T extends PromiseLike<infer U> ? U : T

export type AsyncFunction<P extends readonly any[] = [], R = unknown> = (...args: P) => ToPromise<R>